﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="add.aspx.cs" Inherits="new_add"  validateRequest="false" %>

<%@ Register src="NewsTypeSelect.ascx" tagname="NewsTypeSelect" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../edit/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../edit/xheditor-zh-cn.src.js"></script>
    <script src="../js/jquery.autocomplete.js"  type="text/javascript" language="javascript" ></script>
    <script src="../js/StockSearchData.js" language="javascript" type="text/javascript"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js" language="javascript" type="text/javascript"></script>
     <script type="text/javascript" defer="defer" src="../My97DatePicker/WdatePicker.js"></script>
     
    <script type="text/javascript" language="javascript">
        var selectValue = new Array();
        $(pageInit);
        function pageInit() {
            $('#txtSummary,').xheditor();
            $("#txtContent").xheditor({ upImgUrl: "../upload/newsUpload.aspx", upImgExt: "jpg,jpeg,gif,png" });
        }
        function insertUpload(msg) {
            msg = msg[0];
            $("#uploadList").append('<option value="' + msg.id + '">' + msg.localname + '</option>');
        }
        function submitForm() { $('#frmDemo').submit(); }
        $(document).ready(function () {
            $('#dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 800,
                buttons: {
                    "取消": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        for (var i = 0; i < chks.length; i++) {
                            chks[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (chks[i].value == selectValue[j]) {
                                    chks[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        $("#lblSelectType").html('');
                        var txt = '';
                        var val = "";
                        for (var i = 0; i < chks.length; i++) {
                            var chk = chks[i]
                            if (chk.checked) {
                                txt += $(chk).parent().children("label").html() + ",";
                                val += $(chk).val() + ",";
                            }
                        }
                        if (txt.length == 0) {
                            alert("必须选择一个新闻类型");
                            return;
                        }
                        if (val.length > 0) {
                            val = val.substring(0, val.length - 1);
                            $("#hidSelectValue").val(val);
                        }
                        if (txt.length > 0) {
                            txt = txt.substring(0, txt.length - 1);
                        }
                        $("#lblSelectType").html(txt);
                        $(this).dialog("close");
                    }
                }
            });
            $("#btnSelect").click(function () {
                var chks = $("#DataList1 input[type=checkbox]");

                var vals = $("#hidSelectValue").val().split(",");
                for (var i = 0; i < vals.length; i++) {
                    for (var j = 0; j < chks.length; j++) {
                        if (chks[j].value == vals[i]) {
                            chks[j].checked = true;
                        }
                    }
                }
                selectValue.length = 0;
                for (var i = 0; i < chks.length; i++) {
                    if (chks[i].checked) {
                        selectValue[selectValue.length] = $(chks[i]).val();
                    }
                }
                $('#dialog').dialog('open');
            })
            $("#btnClearUrl").click(function () {
                var content = $("#txtContent").val();
                var rega = /\s/;
                while (rega.test(content)) {
                    content = content.replace(rega, "<br/>");
                }
                $("#txtContent").val(content);
                return false;
            })
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div class="button_bar">
	     <asp:Button ID="btnBack" CssClass="common_button" Text="返回" runat="server" 
             onclick="btnBack_Click" ValidationGroup="22" />
        <asp:Button ID="btnSave" CssClass="common_button" runat="server" Text="保存" 
            onclick="btnSave_Click"   />
    </div>
    <div>
    <table class="query_form_table">
        <tr>
            <th>新闻类型</th>
            <td colspan="3">
                <asp:Label ID="lblSelectType" runat="server" /> <input value="选择" id="btnSelect" type="button" class="common_button" /></td>
        </tr>
      <tr>
            <th>
                标题
            <span style="color:Red">*</span></th>
            <td colspan="3">
                <asp:TextBox ID="txtTitle" runat="server" Width="465px" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="txtTitle" Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
	    <tr>
            <th>
                新闻编号
            </th>
            <td>
                自动
            </td>
             <th>
                机构</th>
            <td><asp:TextBox ID="txtSource" runat="server" /> </td>
        </tr>
        <tr>
           <th>作者</th>
           <td>
                <asp:TextBox ID="txtAuthor" runat="server" />
           </td>
           <th>
                相关股票
           </th>
           <td>
              <asp:TextBox ID="txtStock" runat="server"  />
           </td>
        </tr>
        <tr>
            <th>是否发布</th>
            <td>
                <asp:RadioButton ID="rdoEnableYes" runat="server" value="1" Text="是"
                     GroupName="aa"  />
                <asp:RadioButton ID="rdoEnableNo" runat="server"  Text="否" value="0"  Checked="true" 
                    GroupName="aa" />
              
            </td>
              <th>发布时间</th>
            <td><asp:TextBox ID="txtPTime" runat="server" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" /></td>
        </tr>
        <tr>
            <th>
                新闻重要度
            </th>
            <td>
                <asp:DropDownList ID="ddlStep" runat="server" >
                    <asp:ListItem Value="0">0</asp:ListItem>
                    <asp:ListItem Value="1">1</asp:ListItem>
                    <asp:ListItem Value="2">2</asp:ListItem>
                    <asp:ListItem Value="3">3</asp:ListItem>
                    <asp:ListItem Value="4">4</asp:ListItem>
                    <asp:ListItem Value="5">5</asp:ListItem>
                    <asp:ListItem Value="6">6</asp:ListItem>
                </asp:DropDownList>
            </td>
            <th>
                新闻属性
            </th>
            <td>
                <asp:DropDownList ID="ddlNature" runat="server">
                    <asp:ListItem Value="0">中性</asp:ListItem>
                    <asp:ListItem Value="1">利多</asp:ListItem>
                    <asp:ListItem Value="2">利空</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <th>关键字<span style="color:Red"> *</span></th>
            <td colspan="3" >
                <asp:TextBox ID="txtKeyWords" runat="server" Width="382px" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtKeyWords" Display="Dynamic" ErrorMessage="*" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <th>标题图片</th>
            <td colspan="3" >
                <asp:Image ID="Image1" runat="server" />
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="上传图片" 
                    ValidationGroup="ccc" />
            </td>
        </tr>
        <tr>
            <th>外部链接</th>
            <td colspan="3">
                  <asp:TextBox ID="txtOutsideUrl" runat="server" Width="382px" />
            </td>
        </tr>
        <tr>
            <th>摘要</th>
            <td colspan="3">
                 <asp:TextBox ID="txtSummary" runat="server" Width="80%" Height="113px" TextMode="MultiLine" />
            </td>
        </tr>     
        <tr>
            <th>内容</th>
            <td colspan="3">
                 <asp:TextBox ID="txtContent" runat="server" Width="80%" Height="300px" TextMode="MultiLine" />
                 <br />
                 <asp:Button ID="btnClearUrl" runat="server" Text="文本换行" />
            </td>
        </tr>
    </table>
    </div>
     <div class="button_bar">
        <asp:Button ID="btnBack1" CssClass="common_button" Text="返回" runat="server" 
             onclick="btnBack_Click" ValidationGroup="22" />
        <asp:Button ID="Button2" CssClass="common_button" runat="server" Text="保存" 
            onclick="btnSave_Click"   />
    </div>
    <div id="dialog" title="提示消息">
        <div style="overflow-y:auto; height:450px">
        <p id="content" style="text-align: center">
            <asp:DataList ID="DataList1" runat="server" 
                onitemdatabound="DataList1_ItemDataBound" 
                RepeatDirection="Horizontal" RepeatColumns="1">
                <ItemTemplate>
                    <uc1:NewsTypeSelect ID="NewsTypeSelect1" runat="server" Pid='<%# Eval("id") %>' />
                </ItemTemplate>
            </asp:DataList>
        </p>
        </div>
    </div>
    </form>
</body>
</html>


